package mysql

import (
	"Bluebell/common/resp"
	"Bluebell/models"
	"go.uber.org/zap"
)

func GetCommunityList() (list []*models.Community, err error) {
	DB.Find(&list)
	if list == nil {
		zap.L().Warn("there is no data in db")
		err = nil
	}
	return list, err
}

func GetCommunityDetail(id uint64) (community *models.CommunityDetail, err error) {
	community = new(models.CommunityDetail)
	DB.Where("id=?", id).First(&community)
	if community == nil {
		zap.L().Warn("can not find the data in db")
		err = resp.ErrorInvalidID
	}
	return community, err
}
